package com.github_Dididipapa.shortlink.project.controller;

import com.github_Dididipapa.shortlink.project.common.result.R;
import com.github_Dididipapa.shortlink.project.common.result.Rs;
import com.github_Dididipapa.shortlink.project.dto.resp.LinkAccessLogsRespDTO;
import com.github_Dididipapa.shortlink.project.dto.resp.LinkDaily;
import com.github_Dididipapa.shortlink.project.service.LinkAccessLogsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: To be defined
 * @author: dididi_papa
 * @email: mitis1624087624@gmail.com
 * @date: 2025/09/19  22:35
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/short-link/core/v1")
public class LinkAccessLogsController {

    private final LinkAccessLogsService linkAccessLogsService;

    /**
     * @description: 获取最热门的短链
     * @author: dididi_papa
     * @date: 2025/9/19 下午10:57
     * @param: [fullShortUrl]
     * @return: com.github_Dididipapa.shortlink.project.common.result.R<java.util.List<com.github_Dididipapa.shortlink.project.dto.resp.LinkAccessLogsRespDTO>>
     **/
    @GetMapping("/hot")
    public R<List<LinkAccessLogsRespDTO>> shortLinkHotRank(@RequestParam String fullShortUrl) {
        return Rs.success(linkAccessLogsService.shortLinkHotRank(fullShortUrl));
    }

    /**
     * @description: 统计短链的今日访问数据
     * @author: dididi_papa
     * @date: 2025/9/20 下午5:03
     * @param: [fullShortUrl]
     * @return: com.github_Dididipapa.shortlink.project.common.result.R<com.github_Dididipapa.shortlink.project.dto.resp.LinkDaily>
     **/
    @GetMapping("/daily")
    public R<LinkDaily> shortLinkDailyRank(@RequestParam String fullShortUrl) {
        return Rs.success(linkAccessLogsService.shortLinkDaily(fullShortUrl));
    }
}
